from rest_framework_jwt.views import obtain_jwt_token
from django.conf.urls import url, include
from django.contrib import admin
from meiduo_admin.views.login_view import LoginAPIView
from meiduo_admin.views.home_view import *
from rest_framework.routers import SimpleRouter
from meiduo_admin.views.user_view import *
from meiduo_admin.views.sku_view import *
from meiduo_admin.views.spu_view import *
from meiduo_admin.views.spec_view import *
from meiduo_admin.views.option_view import *
from meiduo_admin.views.image_view import *
from meiduo_admin.views.order_view import *
from meiduo_admin.views.perm_view import *
from meiduo_admin.views.group_view import *
from meiduo_admin.views.admin_view import *
from meiduo_admin.views.channel_view import *
from meiduo_admin.views.brands_view import *

urlpatterns = [

    # url(r'^authorizations/$', LoginAPIView.as_view()),
    url(r'^authorizations/$', obtain_jwt_token),

    # url(r'^statistical/total_count/$', UserTotalCount.as_view()),
    # url(r'^statistical/day_increment/$', UserDayIncreView.as_view()),
    # url(r'^statistical/day_active/$', UserActiveView.as_view()),
    # url(r'^statistical/day_orders/$', UserOrderView.as_view()),
    # url(r'^statistical/month_increment/$', UserMonthIncreView.as_view()),
    url(r'^statistical/goods_day_views/$', GoodsVisitCountView.as_view()),

    url(r'^users/$', UserAPIView.as_view()),

    url(r'^skus/$', SKUViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'^skus/(?P<pk>\d+)/$', SKUViewSet.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy'})),

    url(r'^skus/categories/$', SKUViewSet.as_view({'get': 'categories'})),

    url(r'^goods/simple/$', SPUSimpleView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecSimpleView.as_view()),

    # url(r'^goods/$', SPUViewSet.as_view({'get': 'list', 'post': 'create'})),
    # url(r'^goods/(?P<pk>\d+)/$', SPUViewSet.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy'})),

    url(r'^goods/brands/simple/$', BrandSimpleView.as_view()),
    url(r'^goods/channel/categories/$', GoodsCategoryView.as_view()),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', GoodsCategoryView.as_view()),

    url(r'^goods/specs/simple/$', SpecSimpleView.as_view()),

    url(r'^skus/simple/$', ImageViewSet.as_view({'get': 'simple'})),

    url(r'^orders/$', OrderInfoView.as_view()),
    url(r'^orders/(?P<pk>\d+)/$', OrderInfoView.as_view()),
    url(r'^orders/(?P<pk>\d+)/status/$', OrderInfoView.as_view()),

    url(r'^permission/perms/$', PermViewSet.as_view({'get': 'list', 'post': 'cerate'})),
    url(r'^permission/perms/(?P<pk>\d+)/$', PermViewSet.as_view({'get': 'retrieve',
                                                                 'put': 'update',
                                                                 'delete': 'destroy'})),
    url(r'^permission/content_types/$', ContentTypeView.as_view()),

    url(r'^permission/groups/$', GroupViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'^permission/groups/(?P<pk>\d+)/$', GroupViewSet.as_view({'get': 'list', 'put': 'update', 'delete': 'destroy'})),
    url(r'^permission/simple/$', GroupPermView.as_view()),

    url(r'^permission/admins/$', AdminViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'^permission/admins/(?P<pk>\d+)/$', AdminViewSet.as_view({'get': 'list', 'put': 'update', 'delete': 'destroy'})),
    url(r'^permission/groups/simple/$', AdminGroupView.as_view()),

    url(r'^goods/channels/$', GoodsChannelViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'^goods/channels/(?P<pk>\d+)/$', GoodsChannelViewSet.as_view({'get': 'list', 'put': 'update', 'delete': 'destroy'})),
    url(r'^goods/channel_types/$', GoodsChannelViewSet.as_view({'get': 'channel_types'})),
    url(r'^goods/categories/$', GoodsCategoryView.as_view()),

    url(r'^goods/brands/$', BrandsViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'^goods/brands/(?P<pk>\d+)/$', BrandsViewSet.as_view({'get': 'list', 'put': 'update', 'delete': 'destroy'})),


]

router = SimpleRouter()
router.register(r'statistical', viewset=HomeViewSet, base_name='home')

# /goods/specs/$
router.register(prefix='goods/specs', viewset=SpecViewSet, base_name='specs')
# /goods/(?<pk>[^/.]+)/$
# /goods/$
router.register(prefix='goods', viewset=SPUViewSet, base_name='goods')

router.register(prefix='specs/options', viewset=OptionViewSet, base_name='options')
router.register(prefix='skus/images', viewset=ImageViewSet, base_name='images')

urlpatterns += router.urls

